using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Software.Stone;

namespace NFLog
{
	public partial class FormOptions : Form
	{
		string m_HostNamesText;
		decimal m_depth;
		decimal m_sleeptime;

		public FormOptions()
		{
			InitializeComponent();

			TextHostNames.FatherForm = this;
		}

		public string[] HostNames
		{
			set
			{
				TextHostNames.CommentText = value;
				m_HostNamesText = TextHostNames.Text;
			}
			get
			{
				return TextHostNames.CommentText;
			}
		}

		public int Depth
		{
			set
			{
				m_depth = Convert.ToDecimal(value);

				if (m_depth < numDepth.Minimum)
				{
					numDepth.Value = numDepth.Minimum;
				}
				else if (m_depth > numDepth.Maximum)
				{
					numDepth.Value = numDepth.Maximum;
				}
				else
				{
					numDepth.Value = m_depth;
				}
			}
			get
			{
				return Convert.ToInt32(numDepth.Value);
			}
		}

		public int SleepMinute
		{
			set
			{
				m_sleeptime = Convert.ToDecimal(value);

				if (m_sleeptime < numSleeptime.Minimum)
				{
					numSleeptime.Value = numSleeptime.Minimum;
				}
				else if (m_sleeptime > numSleeptime.Maximum)
				{
					numSleeptime.Value = numSleeptime.Maximum;
				}
				else
				{
					numSleeptime.Value = m_sleeptime;
				}
			}
			get
			{
				return Convert.ToInt32(numSleeptime.Value);
			}
		}

		private void FormOptions_FormClosed(object sender, FormClosedEventArgs e)
		{
			if(m_HostNamesText != TextHostNames.Text || m_depth != numDepth.Value || m_sleeptime != numSleeptime.Value)
			{
				DialogResult = DialogResult.OK;
			}
			else
			{
				DialogResult = DialogResult.Cancel;
			}
		}

		private void btnOK_Click(object sender, EventArgs e)
		{
			Close();
		}
	}
}